<?php
#
# author: Cody Sorgenfrey
# (c)2012 South Hill Calvary Chapel
#

include_once("../mysql/database_info.php");
include_once("common.php");
include_once("../mysql/common.php");

function missionaryBackView($person){

	$first=$person["first"];
	$last=$person["last"];
	$name = $first." ".$last;
	$email=$person["email"];
	$website=$person["website"];
	$facebook=$person["facebook"];
	$blog=$person["blog"];
	$picture="http://www.southhillcalvary.org".$person["picture"];
	$par=$person["bio"];
	$map=$person["map"];
	$search=$person["searchname"];
	$id = $person['id'];
	
	printf("<div class='moreInfoBack' id='back%s'>\n", $person['id']);
	
	printf("<div style='width:%s; text-align:right;'><p onclick='showMore(\"%s\")'>[Read Less]</p></div>\n", "100%", $id);
	
	printf("<div style='width:%s; text-align:center;'><img id='staff' src='%s'></img></div>\n", "100%", $picture);
	
	if ($par){
	
		printf("\t<p>\n");
		
		printf("\t\t%s\n", $par);
	
		printf("\t</p>\n");

	}

	printf("\t<h4>\n");
	
	printf("\t\tMore...\n");
	
	printf("\t</h4>\n");
	
	printf("\t<div class='paragraph'>\n");
	
	printf("\t\t<ul>\n");
	
	if (!empty($email)) {
	
		printf("\t\t\t<li><a href='mailto:%s'>%s</a></li>\n", $email, $email);
	}
	if (!empty($facebook)) {
	
		printf("\t\t\t<li><a href='%s' target='_blank'><img src='http://www.southhillcalvary.org/images/facebook_35x35.png' width='18' height='18'/></a></li>\n", $facebook);
	}
	if (!empty($website)) {
	
		printf("\t\t\t<li><a href='%s' target='_blank'>Website</a></li>\n", $website);
	}
	if (!empty($blog)) {
	
		printf("\t\t\t<li><a href='%s' target='_blank'>Blog</a></li>\n", $blog);
	}
	
	printf("\t\t\t<li><a href='%s' target='_blank'>View Location on Map</a></li>\n", $map);
	
	printf("\t\t</ul>\n");
	
	printf("\t</div>\n");
		
	printf("</div>\n");

	printf("</div>\n");
}

function missionaries($person) {
		
		printf("<div class='infoCard' id='infoCard%s'>\n",$person['id']);
		
		printf("<div class='moreInfoFront' id='front%s'>\n", $person['id']);
		
		printf("<table class='std'>\n");
		
		$location=$person["location"];
		$first=$person["first"];
		$last=$person["last"];
		$email=$person["email"];
		$picture="http://www.southhillcalvary.org".$person["picture"];
		$bio=$person["bio"];
		$name = $first." ".$last;
		
		printf("\t<tr>\n");
		
		printf("\t\t<td width='30px'>\n");
		
		if (!empty($bio)) {
		
			$id=$person["id"];
		
			printf("\t\t<td width='100px'>\n");
		
			printf("<span onclick='showMore(\"%s\")'><img id='staff' src='%s'></a>\n", $id, $picture);
		
			printf("</td>\n", $picture);
		
		} else {
		
			printf("\t\t<td width='100px'><img id='staff' src='%s'></td>\n", $picture);
		}
		
		printf("\t\t<td width='30px'>&nbsp</td>\n");
		
		printf("\t\t<td align='left'>\n");
		
		printf("\t\t\t<TABLE class='std'>\n");
		
		printf("\t\t\t\t<tr><td><strong>%s</strong></td></tr>\n",$name);
		
		printf("\t\t\t\t<tr><td>%s</td></tr>\n",$location);
		
		printf("\t\t\t\t<tr><td><a href='mailto:%s'><p>%s</p></a></td></tr>\n", $email, $email);
		
		if (!empty($bio)) {
		
			printf("\t\t\t\t<tr><td><br/><span onclick='showMore(\"%s\")'>[Read More]</span></td></tr>\n",$id);
		}
		printf("\t\t\t</table>\n");
		
		printf("\t\t</td>\n");
		
		printf("\t<tr><td colspan='3'>&nbsp</td></tr>\n");
		
		printf("</table>\n");
		
		printf("</div>\n");
		
		missionaryBackView($person);
	
	

}

connect_select_test("missionaries");

$title = "Meet our Missionaries";
$meta_key='missions, outreach, support, pastors, foriegn, countries';
$meta_desc="Meet the missionaries South Hill Calvary Chapel supports, and ministers along side of.";
$query="SELECT * FROM `missionaries` ORDER BY `last` ASC";


$morehtml= null;
$morejava= null;

startPageNoPageContent($title, $meta_key, $meta_desc, $morehtml, $morejava);

$result=mysql_query($query) or die (mysql_error());

while ($person = mysql_fetch_array($result)){

	missionaries($person);
}

mysql_close();

endPageNoContent();
?>